import os,glob
import shutil
import tqdm

path = "/media/retoo/RetooDisk/wanghui/Data/character/0326字符检测数据集/"

images = glob.glob(path+"/**/*.jpg",recursive=True)

xml = [p.replace(".jpg",".xml") for p in images]

idx=0
for p,x in tqdm.tqdm(zip(images, xml),total=len(images)):
    if os.path.exists(p) and os.path.exists(x):
        name = str(idx)+"_"+os.path.basename(p)[:-4]
        shutil.copy2(p, "/media/retoo/RetooDisk/wanghui/Data/character/0326字符检测数据集/train/JPEGImages/%s.jpg" % name)
        shutil.copy2(x, "/media/retoo/RetooDisk/wanghui/Data/character/0326字符检测数据集/train/Annotations/%s.xml" % name)
        idx+=1